home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-26 | 2.4 KB | 93 lines | [TEXT/Moml] |
- (* Mosmlrun.sml *)
- (* 1997 Jul 07 e *)
-
- (* interactive use...
- load "Path";
- load "Process";
- load "String";
- load "Substring";
- load "AppleScript";
-
- val home =
- case Process.getEnv "PATH_TRANSLATED" of
- SOME n => Path.dir n
- | NONE => ":"
- ;
- chDir (home ^ "e_SML:");
- *)
-
- (* this only needs to be done once per install...
- let val base = home ^ "src:"
- in
- chDir base; chDir "::";
- link "mosmlcomp.image"
- (true,true) (* -g -noheader *)
- "lorder" (base ^ "mosmllib") [(base ^ "compiler")]
- ["Mainc.uo"]
- end;
- *)
-
- open AppleScript;
-
- exception MosmlrunErr of int * string
-
- fun tell_run_str s =
- "tell application \"mosml142run\"\n «event miscdosc» " ^ s ^ "\nend tell";
-
- fun toStrStr v = "\"" ^ v ^ "\"" ;
-
- fun prefix_ok r =
- String.sub (r,0) = #"\""
- andalso String.sub (r,1) = #" "
- andalso String.sub (r,2) = #"\n"
- ;
-
- fun run_text str =
- let val r = as_run_text (tell_run_str (toStrStr str))
- handle AppleScriptErr (_,s) => s
- in if prefix_ok r
- then let val ss = Substring.trimr 1 (Substring.extract(r, 3, NONE))
- in if Substring.isPrefix str ss
- then let val s1 = Substring.triml (String.size str) ss
- in if Substring.isPrefix "\n? " s1
- then let val s2 = Substring.triml 3 s1
- in if (Substring.size s2) = 0
- then ()
- else raise MosmlrunErr (1, Substring.string s2)
- end
- else raise MosmlrunErr (2, Substring.string s1)
- end
- else raise MosmlrunErr (3, r)
- end
- else raise MosmlrunErr (4, r)
- end
- ;
-
- (*
- run_text "mosmlcomp.image -stdlib :lib -I :e_SML :e_SML:AppleScript.sml";
- run_text "mosmlcomp.image -I :e_SML :e_SML:AppleScript.sml";
- *)
-
- fun concat_prefixing prefix strs =
- String.concat (List.map (fn s => prefix ^ s) strs);
-
- fun mosmlrun_compile lib_str opt_str incl_strs srcfile_str =
- let val incl_str = concat_prefixing " -I " incl_strs
- val s = (String.concat
- ["mosmlcomp.image -stdlib ",lib_str," ",
- opt_str," ",incl_str," ",srcfile_str])
- in print s; print"\n";
- run_text s
- end;
-
- (*
- mosmlrun_compile ":lib" "" [":e_SML"] ":e_SML:AppleScript.sml"
- handle MosmlrunErr(n,s) => print s;
-
- mosmlrun_compile ":lib" "-P none -imptypes" [":e_SML"] ":e_SML:AppleScript.sml"
- handle MosmlrunErr(n,s) => print s;
-
- *)
-
- (* end of mosmlrun.sml *)
-